package com.fzy.designpattern.singleton;

/**
 * 单例饿汉模式 线程安全，访问效率高，懒加载
 *
 * @author 冯赵杨
 * @create 2018/9/14
 */
public class Singleton2 {
    private static volatile Singleton2 instance = null;

    private Singleton2() {
    }

    public static Singleton2 getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null) {
                    instance = new Singleton2();
                }
            }
        }
        return instance;
    }
}
